package com.chenliang.lambda;

import com.chenliang.lambda.po.User;

import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

/**
 * @program: springboot_all
 * @description: 源码看见返回值是一个集合, 一顿操作不会抛出空指针
 * @author: 陈亮
 * @create: 2022-04-09 23:47
 */
public class StreamDemo {


    public static void main(String[] args) {
        Map<String, User> userMap = new HashMap<>();
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setName("陈" + i);
            user.setAge(i);
            userMap.put(String.valueOf(i), user);
        }
        List<String> list = Optional.ofNullable(userMap.get("1")).map(User::getList)
                .orElseGet(Collections::emptyList);
        System.out.println(list);
    }
}
